package com.onec.service.manage.service.redisLock;


import com.onec.service.api.annotation.RedisLock;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class RedisLickServiceImpl implements RedisLickService {
    private int clockNumber = 100;

    /**
     * 测试redis 自实现分布式锁
     */
    @RedisLock
    @Override
    public void addClock() {
        this.clockNumber = clockNumber - 1;
        log.info("当前线程：{},数字减小：{}", Thread.currentThread().getName() + Thread.currentThread().getName(), clockNumber);
        if (clockNumber <= 0) {
            log.info("当前线程：{},数字减小为0：{}", Thread.currentThread().getName() + Thread.currentThread().getName(), clockNumber);

        }
    }
}
